package com.lcy.demo;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.File;

/**
 * Created by 娄存银 on 2017/4/13.
 */
@Path("file")
public class FileServiceImpl implements FileService{
    @Override
    @GET
    @Produces(MediaType.APPLICATION_OCTET_STREAM)
    @Path("{name}")
    public Response getFile(@PathParam("name") String name) {
        File file = new File("D:\\test.xls");
        Response.ResponseBuilder responseBuilder = Response.ok();
        String value = String.format("attachment; filename=%s",file.getName());
        responseBuilder.header("Content-Disposition",value);
        return responseBuilder.build();
    }
}
